#define _CRT_SECURE_NO_WARNINGS
class Parenthesis {
public:
	bool chkParenthesis(string A, int n) {
		// write code here
		if (n % 2 != 0)
			return false;
		if (A[0] == ')')
			return false;
		char* a = new char[100];
		int j = 0;
		for (size_t i = 0; i < A.size(); i++)
		{
			if (A[i] != '(' && A[i] != ')')//
				return false;
			if (A[i] == '(')
			{
				a[j] = '(';
			}
			else
			{
				a[j] = ')';
			}
			if (j > 0 && (a[j - 1] == '(' && a[j] == ')'))
			{
				a[j] = a[j - 1] = '\0';
				j--;
			}
			else
				j++;
		}
		delete[] a;
		return true;
	}
};
